package com.tjhk.java.tech.thread;

public class Machina {
    public Machina(int id) {
        this.id = id;
    }

    public enum State{
        START,ONE,TWO,THREE,FOUR,END;
        State step(){
            if (equals(END)) return END;
            return values()[ordinal()+1];
        }
    }
    private State state = State.START;
    private final int id;

    public static Machina work(Machina m){
        if (!m.state.equals(State.END))
            m.state = m.state.step();
        System.out.println(m.toString());
        return m;
    }

    @Override
    public String toString() {
        return "Machina{" +
                "state=" + state +
                ", id=" + id +
                '}';
    }
}
